package com.lanou.horo.zhuizhui.utility.factory;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.SparseArray;

import com.lanou.horo.zhuizhui.fragment.PersonalMHFragment;
import com.lanou.horo.zhuizhui.fragment.PersonalMPFragment;
import com.lanou.horo.zhuizhui.fragment.PersonalTPFragment;
import com.lanou.horo.zhuizhui.fragment.PersonalTZFragment;

/**
 * Created by dllo on 15/10/26.
 */
public class PersonalFragmentFactory {
    private static SparseArray<Fragment> fragmentMapt = new SparseArray<>();

    public static Fragment createFragment(int position) {
        Fragment f = fragmentMapt.get(position);
        if (f == null) {
            switch (position) {
                case 0:
                    f = new PersonalMHFragment();
                    break;
                case 1:
                    f = new PersonalTZFragment();
                    break;
                case 2:
                    f = new PersonalMPFragment();
                    break;
                case 3:
                    f = new PersonalTPFragment();
                    break;
            }
            Bundle args = new Bundle();
            args.putInt("position",position);
            f.setArguments(args);
            fragmentMapt.put(position, f);
        }
        return f;
    }
}
